<template>
  <rx-layout>
    <div slot="center" style>
      <rx-fit :isheader="isheader">
        <div slot="toolheader" foldheader="true" foldbtn="false" border="false">
          <div class="table-operator">
            <a-button v-if="addEnable" type="primary" icon="plus" @click="add">{{$ti18('rxList.add','新增')}}</a-button>

          </div>
          <span class="search-btn-box" v-if="!isheader">
            <span class="search-btn" @click.stop="searchshow"><i class="iconfont iconguolv"></i>{{$ti18('rxList.leachBtn','过滤')}}</span>
          </span>
        </div>
        <div  btnalign="right" slot="searchbar" v-if="fitSearch" @search="search" @cancel="cancel"
             @close="closeSearchbar">
          <a-form :layout="colLayout">
            <a-row :gutter="24">
              <a-col :span="colSpan">
                <a-form-item :label="i18n('form.name','名称')">
                  <a-input :placeholder="i18n('form.name','名称','input')" v-model="queryParam.Q_NAME__S_LK"/>
                </a-form-item>
              </a-col>
              <a-col :span="colSpan">
                <a-form-item :label="i18n('form.status','状态')">
                  <a-select allowClear :placeholder="i18n('form.status','状态','select')" :options="statusOpt" v-model="queryParam.Q_STATUS__S_LK"/>
                </a-form-item>
              </a-col>
            </a-row>
          </a-form>
        </div>
        <rx-grid
          ref="table"
          :bordered="isBorder"
          :multiSelect="true"
          :columns="columns"
          :defaultPageSize="10"
          url="/api-system/system/core/sysTransferSetting/query"
          :queryParam="queryParam"
          data-field="result.data"
          :pageSizeOptions="['10','30','40']"
          id-field="id"
          @selectChange="onSelectChange"
          :getCheckboxProps="getCheckboxProps"
        >

          <span slot="status" slot-scope="{text,record,index}" >
               <a-tag :color="statusMap[text].color">
                  <span>{{ statusMap[text].text }}</span>
                </a-tag>
          </span>
          <span slot="action" slot-scope="{ text, record }" class="actionIcons">
            <span v-if="canEdit(record)"  @click.stop="edit(record)">{{$ti18('rxList.editBtn','编辑')}}</span>
            <span v-if="!canEdit(record)"  >{{$ti18('rxList.editBtn','编辑')}}</span>
            <span v-if="canEdit(record)" @click.stop="delByIds([record.id])">{{$ti18('rxList.delBtn','删除')}}</span>
            <span v-if="!canEdit(record)"   >{{$ti18('rxList.delBtn','删除')}}</span>
          </span>
        </rx-grid>
      </rx-fit>
    </div>
  </rx-layout>
</template>

<script>
  import SysTransferSettingApi from '@/api/system/core/sysTransferSetting'
  import SysTransferSettingEdit from './SysTransferSettingEdit'
  import {BaseList} from "@lowcode/jpaas-common-lib";
  import userState from "@/assets/js/userState";

  export default {
    name: 'SysTransferSettingList',
    mixins: [BaseList,userState],
    components: {},
    data() {
      return {
        columns: [
          {
            title: this.$ti18('rxList.index','序号'),
            type: 'indexColumn',
            width: 40,
            dataIndex: 'serial',
            scopedSlots: {customRender: 'serial'}
          },
          {title: this.i18n('form.name','名称'), dataIndex: 'name', width: 120},
          {title: this.i18n('form.status','状态'), dataIndex: 'status', width: 120, scopedSlots: {customRender: 'status'}},
          {title: this.$ti18('rxForm.createTime','创建时间'), dataIndex: 'createTime', width: 120},
          {title: this.$ti18('rxList.action','操作'), dataIndex: 'action', scopedSlots: {customRender: 'action'}, width: 60}
        ],
        component: SysTransferSettingEdit,
        comment: this.i18n('list.comment','权限转移设置表'),
        widthHeight: ['1100px', '600px'],
        statusOpt: [{label: this.i18n('form.enable','启用'), value: 'YES'}, {label: this.i18n('form.disable','禁用'), value: 'NO'}],
          statusMap: {
              "YES": {color: 'green', text: this.i18n('form.enable','启用')},
              "NO": {color: 'red', text: this.i18n('form.disable','禁用')},
          },
      }
    },
    methods: {
      i18n(name,text,key){
          return this.$ti18(name,text,"SysTransferSetting",key);
      },
      delById(ids) {
        return SysTransferSettingApi.del({ids: ids.join(',')});
      },
      getListByParams(parameter) {
        return SysTransferSettingApi.query(parameter)
      },
      search() {
        this.$refs.table.loadData()
      },
      cancel() {
        this.resetSearch()
      },
      closeSearchbar() {
        //关闭过滤弹窗；（点击X触发）
        this.fitSearch = false;
      },
    }
  }
</script>
<style scoped>

</style>

